﻿CREATE PROCEDURE [dbo].[proc_Company_Update]
	(
	@CompanyName nvarchar(50),
	 @Startletter nvarchar(50),
	 @CompanyNumber nvarchar(50),
	 @CompanyPhone nvarchar(50),
	 @CompanyFax nvarchar(50),
	 @CompanyAddress nvarchar(100),
	 @Zip nvarchar(10),
	 @ContactPerson nvarchar(20),
	 @ContactPhone nvarchar(20),
	 @ContactEmail nvarchar(50),
	 @WebAddress nvarchar(50),
	 @Products nvarchar(2000),
	 @CompanyAllName nvarchar(50),
	 @Mid int,
	 @Id INT,
	 @CompanyFR NVARCHAR(50),
	 @CreateDate datetime
	)
AS
	Update Company Set
	CompanyName=@CompanyName,
	Startletter=@Startletter,
	CompanyNumber=@CompanyNumber,
	CompanyPhone=@CompanyPhone,
	CompanyFax=@CompanyFax,
	CompanyAddress=@CompanyAddress,
	Zip=@Zip,
	ContactPerson=@ContactPerson,
	ContactPhone=@ContactPhone,
	ContactEmail=@ContactEmail,
	WebAddress=@WebAddress,
	Products=@Products,
	CompanyAllName=@CompanyAllName,
	Mid=@Mid,
	CompanyFR=@CompanyFR,
	CreateDate=@CreateDate
	Where Id=@Id
	
	--修改组织架构
	UPDATE ManagementArea
	SET			
		CompanyName = @CompanyName,
		Startletter = @Startletter,
		CompanyPhone = @CompanyPhone,
		CompanyFax = @CompanyFax,
		CompanyAddress = @CompanyAddress,
		Zip = @Zip,
		ContactPerson = @ContactPerson,
		ContactPhone = @ContactPhone,
		ContactEmail = @ContactEmail,
		WebAddress = @WebAddress,
		Products = @Products,
		CompanyNumber = @CompanyNumber		
	WHERE zid=(SELECT bh FROM zzjg z WHERE z.CompanyId=@Id AND flag=1)
	
	UPDATE zzjg
	SET				
		name = @CompanyName,
		sort = @CompanyNumber	
	WHERE CompanyId=@Id AND flag=1
	
	--修改组织架构
	
	RETURN
